<!DOCTYPE html>












  


<html class="theme-next muse use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">






  
  
    
      
    
    
      
    
  <script src="//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js"></script>
  <link href="//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/blue/pace-theme-flash.min.css" rel="stylesheet">



<script>
    (function () {
        if ('') {
            if (prompt('请输入文章密码') !== '') {
                alert('密码错误！');
                if (history.length === 1) {
                    location.replace("http://xxxxxxx.xxx"); // 这里替换成你的首页
                } else {
                    history.back();
                }
            }
        }
    })();
</script>





<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">



  <meta name="google-site-verification" content="zrNUWIf25v2J4dC1wliso_DUXEwYoECv4j3h9CE34xM">








  <meta name="baidu-site-verification" content="nuHze5uXZ7">







  
  
    
  
  <link href="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet" type="text/css">




  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  

  
    
      
    

    
  

  
    
    
    <link href="https://fonts.cat.net/css?family=Lato:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Roboto Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






  

<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">




<link href="/css/main.css?v=6.4.2" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.4.2">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.ico?v=6.4.2">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.4.2">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.2" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '6.4.2',
    sidebar: {"position":"left","display":"always","offset":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="之前的一篇文章写了用Hexo和GitHub搭建博客，现在就来对博客主题做一些个性化的修改。">
<meta name="keywords" content="Hexo,Next,美化,配置">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo设置及Next主题美化">
<meta property="og:url" content="https://blog.codenote.pro/hexo-settings-and-next-theme-beautification.html">
<meta property="og:site_name" content="九阳的笔记本">
<meta property="og:description" content="之前的一篇文章写了用Hexo和GitHub搭建博客，现在就来对博客主题做一些个性化的修改。">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://p3vld0dkf.bkt.clouddn.com/%E6%9D%A5%E5%BF%85%E5%8A%9B.png">
<meta property="og:image" content="http://p3vld0dkf.bkt.clouddn.com/LeanCloud.png">
<meta property="og:image" content="http://p3vld0dkf.bkt.clouddn.com/LeanCloudKey.png">
<meta property="og:image" content="http://p3vld0dkf.bkt.clouddn.com/LeanCloud%E5%AE%89%E5%85%A8%E5%9F%9F%E5%90%8D.png">
<meta property="og:updated_time" content="2018-10-29T14:22:48.756Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hexo设置及Next主题美化">
<meta name="twitter:description" content="之前的一篇文章写了用Hexo和GitHub搭建博客，现在就来对博客主题做一些个性化的修改。">
<meta name="twitter:image" content="http://p3vld0dkf.bkt.clouddn.com/%E6%9D%A5%E5%BF%85%E5%8A%9B.png">



  <link rel="alternate" href="/atom.xml" title="九阳的笔记本" type="application/atom+xml">




  <link rel="canonical" href="https://blog.codenote.pro/hexo-settings-and-next-theme-beautification.html">



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>Hexo设置及Next主题美化 | 九阳的笔记本</title>
  




<script async src="https://www.googletagmanager.com/gtag/js?id=UA-126970002-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-126970002-1');
</script>



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?07b2f6778635ec267ee2b4753e118da9";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
     
    
    
    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">九阳的笔记本</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-hexo">
    <a href="/categories/Hexo" rel="section">
      <i class="menu-item-icon fa fa-fw fa-header"></i> <br>Hexo</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-linux">
    <a href="/categories/Linux" rel="section">
      <i class="menu-item-icon fa fa-fw fa-linux"></i> <br>Linux</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-docker">
    <a href="/categories/docker" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>docker</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-learn">
    <a href="/categories/learn" rel="section">
      <i class="menu-item-icon fa fa-fw fa-leanpub"></i> <br>学习</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-top">
    <a href="/top/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-signal"></i> <br>阅读排行</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-sitemap">
    <a href="/sitemap.xml" rel="section">
      <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br>站点地图</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
        </li>
      
    </ul>
  

  
    

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://blog.codenote.pro/hexo-settings-and-next-theme-beautification.html">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="yszar">
      <meta itemprop="description" content="学无止境！">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="九阳的笔记本">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">Hexo设置及Next主题美化
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-09-28 15:51:07" itemprop="dateCreated datePublished" datetime="2018-09-28T15:51:07+08:00">2018-09-28</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2018-10-29 22:22:48" itemprop="dateModified" datetime="2018-10-29T22:22:48+08:00">2018-10-29</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/Hexo/" itemprop="url" rel="index"><span itemprop="name">Hexo</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/hexo-settings-and-next-theme-beautification.html" class="leancloud_visitors" data-flag-title="Hexo设置及Next主题美化">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数：</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          
              <div class="post-description">之前的一篇文章写了用Hexo和GitHub搭建博客，现在就来对博客主题做一些个性化的修改。</div>
          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p></p><p class="description">之前的一篇文章写了用Hexo和GitHub搭建博客，现在就来对博客主题做一些个性化的修改。</p><br><a id="more"></a><p></p>
<h3 id="安装Next主题"><a href="#安装Next主题" class="headerlink" title="安装Next主题"></a><a href="#安装Next主题" title="安装Next主题"></a>安装Next主题</h3><p>切换到博客的目录，使用<code>Git Bash</code>运行下载主题：  </p>
<figure class="highlight bash"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line">git <span class="built_in">clone</span> https://github.com/iissnan/hexo-theme-next themes/next</div></pre></div></div></figure>
<p>然后打开<strong>根目录</strong>下的<code>_config.yml</code>，注意这个是整个博客站点的配置文件，而<strong>主题目录</strong>下也有一个<code>_config.yml</code>，这是主题的配置文件。在站点配置文件找到<code>theme</code>改为<code>next</code>：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line"><span class="attr">theme:</span> <span class="string">next</span></div></pre></div></div></figure>
<p>这样就启用了主题，可以运行<code>hexo s</code>查看效果了。</p>
<h3 id="博客设置"><a href="#博客设置" class="headerlink" title="博客设置"></a><a href="#博客设置" title="博客设置"></a>博客设置</h3><p>这里先对博客基本信息做一些设置，<strong>注意了，设置时冒号后面都要有一个空格，这是yml文件的格式</strong></p>
<h4 id="设置语言"><a href="#设置语言" class="headerlink" title="设置语言"></a><a href="#设置语言" title="设置语言"></a>设置语言</h4><p>首先先设置博客站点的语言，这个是在站点配置文件，也就是<strong>根目录</strong>下的<code>_config.yml</code>设置的，找到<code>language</code>设置成中文：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line"><span class="attr">language:</span> <span class="string">zh-Hans</span></div></pre></div></div></figure>
<h4 id="基本信息"><a href="#基本信息" class="headerlink" title="基本信息"></a><a href="#基本信息" title="基本信息"></a>基本信息</h4><p>在站点配置文件的开头，填上自己博客的相应信息：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></div><div class="code"><pre><div class="line"><span class="attr">title:</span> <span class="comment"># 标题  </span></div><div class="line"><span class="attr">subtitle:</span> <span class="comment"># 副标题  </span></div><div class="line"><span class="attr">description:</span> <span class="comment"># 站点描述  </span></div><div class="line"><span class="attr">author:</span> <span class="comment"># 作者  </span></div><div class="line"><span class="attr">language:</span> <span class="string">zh-Hans</span>  </div><div class="line"><span class="attr">timezone:</span></div></pre></div></div></figure>
<h3 id="主题设置"><a href="#主题设置" class="headerlink" title="主题设置"></a><a href="#主题设置" title="主题设置"></a>主题设置</h3><p>Next已经自带了很多功能和集成了一些第三方服务，通过主题目录下的<code>_config.yml</code>就能对主题做一些设定及个性化。</p>
<h4 id="设置主题的Scheme"><a href="#设置主题的Scheme" class="headerlink" title="设置主题的Scheme"></a><a href="#设置主题的Scheme" title="设置主题的Scheme"></a>设置主题的Scheme</h4><p>Next自带了几种外观，在主题目录的<code>_config.yml</code>里找到<code>scheme</code>，我比较喜欢Mist，把前面的注释符<code>#</code>去掉即可：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></div><div class="code"><pre><div class="line"><span class="comment">#scheme: Muse  </span></div><div class="line"><span class="attr">scheme:</span> <span class="string">Mist</span>  </div><div class="line"><span class="comment">#scheme: Pisces  </span></div><div class="line"><span class="comment">#scheme: Gemini</span></div></pre></div></div></figure>
<h4 id="菜单设置"><a href="#菜单设置" class="headerlink" title="菜单设置"></a><a href="#菜单设置" title="菜单设置"></a>菜单设置</h4><p>我们可以看到首页有还有归档等菜单，这些在主题配置文件里设置，找到<code>menu</code>，把需要的菜单取消注释，我这里保留了<code>categories</code>分类，<code>tags</code>标签，<code>archives</code>归档，<code>about</code>关于，<code>||</code>后面的表示图标，使用<code>Font Awesome</code>图标名字。我就不作修改了：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></div><div class="code"><pre><div class="line"><span class="attr">menu:</span>  </div><div class="line"><span class="attr"> home:</span> <span class="string">/</span> <span class="string">||</span> <span class="string">home</span>  </div><div class="line"><span class="attr"> categories:</span> <span class="string">/categories/</span> <span class="string">||</span> <span class="string">th</span>  </div><div class="line"><span class="attr"> tags:</span> <span class="string">/tags/</span> <span class="string">||</span> <span class="string">tags</span>  </div><div class="line"><span class="attr"> archives:</span> <span class="string">/archives/</span> <span class="string">||</span> <span class="string">archive</span>  </div><div class="line"><span class="attr"> about:</span> <span class="string">/about/</span> <span class="string">||</span> <span class="string">user</span>  </div><div class="line"> <span class="comment">#schedule: /schedule/ || calendar  </span></div><div class="line"> <span class="comment">#sitemap: /sitemap.xml || sitemap  </span></div><div class="line"> <span class="comment">#commonweal: /404/ || heartbeat</span></div></pre></div></div></figure>
<p>另外，也可以自己添加菜单，但我暂时没有这个需要。</p>
<h4 id="创建页面"><a href="#创建页面" class="headerlink" title="创建页面"></a><a href="#创建页面" title="创建页面"></a>创建页面</h4><p>设置完菜单但是没有页面的话点击菜单就会报错了。创建刚才建了菜单的页面执行以下命令：  </p>
<figure class="highlight bash"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></div><div class="code"><pre><div class="line">hexo new page tags  </div><div class="line">hexo new page categories  </div><div class="line">hexo new page about</div></pre></div></div></figure>
<p>然后在<code>source</code>目录下就会生成对应的文件夹，每个文件夹里都有一个<code>index.md</code>，打开将页面的<code>type</code>设置为相应的内容。  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></div><div class="code"><pre><div class="line"><span class="attr">title:</span> <span class="string">标签</span>  </div><div class="line"><span class="attr">date:</span>   </div><div class="line"><span class="attr">type:</span> <span class="string">"tags"</span> <span class="comment"># 或者 "categories"/"about"  </span></div><div class="line"><span class="attr">comments:</span> <span class="literal">false</span>  </div><div class="line"><span class="meta">---</span></div></pre></div></div></figure>
<p><code>comments</code>是关闭这个页面的评论功能用的，评论后面会提到。</p>
<h4 id="文章显示设置"><a href="#文章显示设置" class="headerlink" title="文章显示设置"></a><a href="#文章显示设置" title="文章显示设置"></a>文章显示设置</h4><p>默认首页的文章会显示全文，在主题配置文件设置<code>auto_excerpt</code>为<code>true</code>再设置长度就会只显示你设置的字数了。  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></div><div class="code"><pre><div class="line"><span class="attr">auto_excerpt:</span>  </div><div class="line"><span class="attr"> enable:</span> <span class="literal">true</span>  </div><div class="line"><span class="attr"> length:</span> <span class="number">100</span></div></pre></div></div></figure>
<p>但是，官方是不推荐这种做法的，我这里用的方法是发表的文章的开头加上<code>description</code>，这样，文章就会显示这个摘要：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></div><div class="code"><pre><div class="line"><span class="attr">title:</span> <span class="comment"># 文章标题  </span></div><div class="line"><span class="attr">author:</span> <span class="comment"># 作者  </span></div><div class="line"><span class="attr">tags:</span>   </div><div class="line"><span class="bullet"> -</span> <span class="string">Hexo</span>  </div><div class="line"><span class="bullet"> -</span> <span class="string">Next</span>  </div><div class="line"><span class="attr">categories:</span>   </div><div class="line"><span class="bullet"> -</span> <span class="string">Hexo</span>  </div><div class="line"><span class="bullet"> -</span> <span class="string">Next</span>  </div><div class="line"><span class="attr">description:</span> <span class="comment"># 描述，首页文章显示的摘要  </span></div><div class="line"><span class="attr">date:</span>   </div><div class="line"><span class="meta">---</span></div></pre></div></div></figure>
<p>这里的<code>tags</code>和<code>categories</code>就是给文章加上标签和分类，两者的区别就是<code>categories</code>是有层级的，像上面那样分类里<code>Next</code>就是<code>Hexo</code>的子类，Hexo是不支持指定多个同级分类的。</p>
<h4 id="使用RSS"><a href="#使用RSS" class="headerlink" title="使用RSS"></a><a href="#使用RSS" title="使用RSS"></a>使用RSS</h4><p>先在博客目录下执行以下命令安装插件：  </p>
<figure class="highlight bash"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line">npm install --save hexo-generator-feed</div></pre></div></div></figure>
<p>然后在主题配置文件里找到<code>rss</code>修改：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line"><span class="attr">rss:</span> <span class="string">/atom.xml</span></div></pre></div></div></figure>
<p>之后在右边的侧边栏就能看到RSS按钮了</p>
<h4 id="设置头像"><a href="#设置头像" class="headerlink" title="设置头像"></a><a href="#设置头像" title="设置头像"></a>设置头像</h4><p>在<code>source</code>目录下新建一个<code>images</code>目录，放一张名为<code>avatar.png</code>的头像，修改主题配置文件的<code>avatar</code>字段：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line"><span class="attr">avatar:</span> <span class="string">/images/avatar.png</span></div></pre></div></div></figure>
<h4 id="设置博客favicon图标"><a href="#设置博客favicon图标" class="headerlink" title="设置博客favicon图标"></a><a href="#设置博客favicon图标" title="设置博客favicon图标"></a>设置博客favicon图标</h4><p>在<code>images</code>目录下放置图标，我这里放了两种大小的ico图标，然后在主题配置文件找到<code>favicon</code>并修改：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></div><div class="code"><pre><div class="line"><span class="attr">favicon:</span>   </div><div class="line"><span class="attr"> small:</span> <span class="string">/images/favicon-16x16.ico</span>  </div><div class="line"><span class="attr"> medium:</span> <span class="string">/images/favicon-32x32.ico</span>  </div><div class="line"> <span class="comment">#apple\_touch\_icon: /images/apple-touch-icon-next.png  </span></div><div class="line"> <span class="comment">#safari\_pinned\_tab: /images/logo.svg  </span></div><div class="line"> <span class="comment">#android_manifest: /images/manifest.json  </span></div><div class="line"> <span class="comment">#ms_browserconfig: /images/browserconfig.xml</span></div></pre></div></div></figure>
<h4 id="侧边栏社交链接"><a href="#侧边栏社交链接" class="headerlink" title="侧边栏社交链接"></a><a href="#侧边栏社交链接" title="侧边栏社交链接"></a>侧边栏社交链接</h4><p>在主题配置文件找到<code>social</code>把需要的取消注释，然后填好你的链接就可以了，<code>||</code>后面的是图标名称，和菜单的一样，也是使用<code>Font Awesome</code>图标名字。  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></div><div class="code"><pre><div class="line"><span class="attr">social:</span>  </div><div class="line"><span class="attr"> GitHub:</span> <span class="attr">https://github.com/JianFengY</span> <span class="string">||</span> <span class="string">github</span>  </div><div class="line"><span class="attr"> GMail:</span> <span class="attr">mailto:yjianfengxy@gmail.com</span> <span class="string">||</span> <span class="string">envelope</span>  </div><div class="line"> <span class="comment">#Google: https://plus.google.com/yourname || google  </span></div><div class="line"> <span class="comment">#Twitter: https://twitter.com/yourname || twitter  </span></div><div class="line"><span class="attr"> Facebook:</span> <span class="attr">https://www.facebook.com/jf.young.1</span> <span class="string">||</span> <span class="string">facebook</span>  </div><div class="line"> <span class="comment">#VK Group: https://vk.com/yourname || vk  </span></div><div class="line"> <span class="comment">#StackOverflow: https://stackoverflow.com/yourname || stack-overflow  </span></div><div class="line"> <span class="comment">#YouTube: https://youtube.com/yourname || youtube  </span></div><div class="line"> <span class="comment">#Instagram: https://instagram.com/yourname || instagram  </span></div><div class="line"> <span class="comment">#Skype: skype:yourname?call|chat || skype</span></div></pre></div></div></figure>
<p>你也可以自行添加其他社交方式，按照格式添加即可。</p>
<h4 id="设置背景动画"><a href="#设置背景动画" class="headerlink" title="设置背景动画"></a><a href="#设置背景动画" title="设置背景动画"></a>设置背景动画</h4><p>同样是主题配置文件，我这里用的是<code>canvas_nest</code>：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></div><div class="code"><pre><div class="line"><span class="comment"># Canvas-nest  </span></div><div class="line"><span class="attr">canvas_nest:</span> <span class="literal">true</span>  </div><div class="line">  </div><div class="line"><span class="comment"># three_waves  </span></div><div class="line"><span class="attr">three_waves:</span> <span class="literal">false</span>  </div><div class="line">  </div><div class="line"><span class="comment"># canvas_lines  </span></div><div class="line"><span class="attr">canvas_lines:</span> <span class="literal">false</span>  </div><div class="line">  </div><div class="line"><span class="comment"># canvas_sphere  </span></div><div class="line"><span class="attr">canvas_sphere:</span> <span class="literal">false</span></div></pre></div></div></figure>
<h4 id="修改文章底部的-号标签"><a href="#修改文章底部的-号标签" class="headerlink" title="修改文章底部的#号标签"></a><a href="#修改文章底部的-号标签" title="修改文章底部的#号标签"></a>修改文章底部的#号标签</h4><p>打开<code>/themes/next/layout/_macro/post.swig</code>，搜索 <code>rel=&quot;tag&quot;&gt;#</code>，将<code>#</code>换成<code>Font Awesome</code>图标:  </p>
<figure class="highlight html"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">i</span> <span class="attr">class</span>=<span class="string">"fa fa-tag"</span>&gt;</span><span class="tag">&lt;/<span class="name">i</span>&gt;</span></div></pre></div></div></figure>
<h4 id="评论系统"><a href="#评论系统" class="headerlink" title="评论系统"></a><a href="#评论系统" title="评论系统"></a>评论系统</h4><p>我使用的是来必力 <a href="https://livere.com/" rel="external nofollow noopener noreferrer" target="_blank">点击这里</a> 注册账号，然后复制下面的<code>data-uid</code>：<br><img src="http://p3vld0dkf.bkt.clouddn.com/%E6%9D%A5%E5%BF%85%E5%8A%9B.png" alt="来必力"></p>
<p>在主题配置文件找到<code>livere_uid</code>：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></div><div class="code"><pre><div class="line"><span class="comment"># Support for LiveRe comments system.  </span></div><div class="line"><span class="comment"># You can get your uid from https://livere.com/insight/myCode (General web site)  </span></div><div class="line"><span class="attr">livere_uid:</span> <span class="comment"># 粘贴你的uid</span></div></pre></div></div></figure>
<p>这样，除了设置了<code>comments: false</code>的页面，其他都会有评论系统了。</p>
<h4 id="网站底部加访问量"><a href="#网站底部加访问量" class="headerlink" title="网站底部加访问量"></a><a href="#网站底部加访问量" title="网站底部加访问量"></a>网站底部加访问量</h4><p>这个我是通过修改<code>\themes\next\layout\_partials\footer.swig</code>文件实现的:  </p>
<figure class="highlight html"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></div><div class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"powered-by"</span>&gt;</span>  </div><div class="line"> <span class="tag">&lt;<span class="name">i</span> <span class="attr">class</span>=<span class="string">"fa fa-user-md"</span>&gt;</span><span class="tag">&lt;/<span class="name">i</span>&gt;</span>  </div><div class="line"> <span class="tag">&lt;<span class="name">span</span> <span class="attr">id</span>=<span class="string">"busuanzi\_container\_site_uv"</span>&gt;</span>  </div><div class="line"> 本站访客数:<span class="tag">&lt;<span class="name">span</span> <span class="attr">id</span>=<span class="string">"busuanzi\_value\_site_uv"</span>&gt;</span><span class="tag">&lt;/<span class="name">span</span>&gt;</span>  </div><div class="line"> <span class="tag">&lt;/<span class="name">span</span>&gt;</span>  </div><div class="line"> <span class="tag">&lt;<span class="name">span</span> <span class="attr">class</span>=<span class="string">"post-meta-divider"</span>&gt;</span>|<span class="tag">&lt;/<span class="name">span</span>&gt;</span>  </div><div class="line"> <span class="tag">&lt;<span class="name">span</span> <span class="attr">id</span>=<span class="string">"busuanzi\_container\_site_pv"</span>&gt;</span>  </div><div class="line"> 本站访问量<span class="tag">&lt;<span class="name">span</span> <span class="attr">id</span>=<span class="string">"busuanzi\_value\_site_pv"</span>&gt;</span><span class="tag">&lt;/<span class="name">span</span>&gt;</span>  </div><div class="line"> <span class="tag">&lt;/<span class="name">span</span>&gt;</span>  </div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div></pre></div></div></figure>
<h4 id="统计功能"><a href="#统计功能" class="headerlink" title="统计功能"></a><a href="#统计功能" title="统计功能"></a>统计功能</h4><p>先在博客目录下安装插件：  </p>
<figure class="highlight bash"><div class="figcode"><div class="gutter"><pre><div class="line">1</div></pre></div><div class="code"><pre><div class="line">npm install hexo-wordcount --save</div></pre></div></div></figure>
<p>然后在主题配置文件，找到<code>post_wordcount</code>，修改你想要的统计功能，有字数统计，阅读时长等：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></div><div class="code"><pre><div class="line"><span class="comment"># Post wordcount display settings  </span></div><div class="line"><span class="comment"># Dependencies: https://github.com/willin/hexo-wordcount  </span></div><div class="line"><span class="attr">post_wordcount:</span>  </div><div class="line"><span class="attr"> item_text:</span> <span class="literal">true</span>  </div><div class="line"><span class="attr"> wordcount:</span> <span class="literal">true</span>  </div><div class="line"><span class="attr"> min2read:</span> <span class="literal">true</span>  </div><div class="line"><span class="attr"> totalcount:</span> <span class="literal">true</span>  </div><div class="line"><span class="attr"> separated_meta:</span> <span class="literal">true</span></div></pre></div></div></figure>
<h4 id="LeanCloud文章阅读次数统计"><a href="#LeanCloud文章阅读次数统计" class="headerlink" title="LeanCloud文章阅读次数统计"></a><a href="#LeanCloud文章阅读次数统计" title="LeanCloud文章阅读次数统计"></a>LeanCloud文章阅读次数统计</h4><p><a href="https://leancloud.cn/dashboard/applist.html#/apps" rel="external nofollow noopener noreferrer" target="_blank">点击这里</a> 注册登录LeanCloud账号，先创建一个任意名称的应用，再创建一个名为<code>Counter</code>的<code>Class</code>。<br><img src="http://p3vld0dkf.bkt.clouddn.com/LeanCloud.png" alt="LeanCloud"><br>在应用Key这里分别复制<code>App ID</code>和<code>App Key</code>到主题配置文件里的<code>leancloud_visitors</code>，并把<code>enable</code>改为<code>true</code>。<br><img src="http://p3vld0dkf.bkt.clouddn.com/LeanCloudKey.png" alt="Key">  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></div><div class="code"><pre><div class="line"><span class="comment"># Show number of visitors to each article.  </span></div><div class="line"><span class="comment"># You can visit https://leancloud.cn get AppID and AppKey.  </span></div><div class="line"><span class="attr">leancloud_visitors:</span>  </div><div class="line"><span class="attr"> enable:</span> <span class="literal">true</span>  </div><div class="line"><span class="attr"> app_id:</span>   </div><div class="line"><span class="attr"> app_key:</span></div></pre></div></div></figure>
<p>然后最好再设置一下安全域名就可以了：<br><img src="http://p3vld0dkf.bkt.clouddn.com/LeanCloud%E5%AE%89%E5%85%A8%E5%9F%9F%E5%90%8D.png" alt="安全域名"></p>
<h4 id="搜索服务Local-Search"><a href="#搜索服务Local-Search" class="headerlink" title="搜索服务Local Search"></a><a href="#搜索服务Local-Search" title="搜索服务Local Search"></a>搜索服务Local Search</h4><p>先安装<code>hexo-generator-searchdb</code>，博客目录执行：  </p>
<figure class="highlight bash"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></div><div class="code"><pre><div class="line">npm install hexo-generator-searchdb --save</div><div class="line">```  </div><div class="line"></div><div class="line">然后在站点配置文件，**注意不是主题配置**，添加以下代码：  </div><div class="line"></div><div class="line"></div><div class="line">```yml</div><div class="line">search:  </div><div class="line"> path: search.xml  </div><div class="line"> field: post  </div><div class="line"> format: html  </div><div class="line"> <span class="built_in">limit</span>: 10000</div></pre></div></div></figure>
<p>然后主题配置文件找到<code>local_search</code>改为<code>true</code>，然后从上面提供的样式选一个填入<code>pace_theme</code>中就可以了：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></div><div class="code"><pre><div class="line"><span class="comment"># Local search  </span></div><div class="line"><span class="attr">local_search:</span>  </div><div class="line"><span class="attr"> enable:</span> <span class="literal">true</span></div></pre></div></div></figure>
<p>然后菜单就会出现搜索了。</p>
<h4 id="顶部加载条"><a href="#顶部加载条" class="headerlink" title="顶部加载条"></a><a href="#顶部加载条" title="顶部加载条"></a>顶部加载条</h4><p>修改主题配置文件，找到<code>pace</code>改为<code>true</code>，并从上面提供的样式中选择一种填入<code>pace_theme</code>中就可以了：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></div><div class="code"><pre><div class="line"><span class="comment"># Progress bar in the top during page loading.  </span></div><div class="line"><span class="attr">pace:</span> <span class="literal">true</span>  </div><div class="line"><span class="comment"># Themes list:  </span></div><div class="line"><span class="comment">#pace-theme-big-counter  </span></div><div class="line"><span class="comment">#pace-theme-bounce  </span></div><div class="line"><span class="comment">#pace-theme-barber-shop  </span></div><div class="line"><span class="comment">#pace-theme-center-atom  </span></div><div class="line"><span class="comment">#pace-theme-center-circle  </span></div><div class="line"><span class="comment">#pace-theme-center-radar  </span></div><div class="line"><span class="comment">#pace-theme-center-simple  </span></div><div class="line"><span class="comment">#pace-theme-corner-indicator  </span></div><div class="line"><span class="comment">#pace-theme-fill-left  </span></div><div class="line"><span class="comment">#pace-theme-flash  </span></div><div class="line"><span class="comment">#pace-theme-loading-bar  </span></div><div class="line"><span class="comment">#pace-theme-mac-osx  </span></div><div class="line"><span class="comment">#pace-theme-minimal  </span></div><div class="line"><span class="comment"># For example  </span></div><div class="line"><span class="comment"># pace_theme: pace-theme-center-simple  </span></div><div class="line"><span class="attr">pace_theme:</span> <span class="string">pace-theme-minimal</span></div></pre></div></div></figure>
<h4 id="右上角加fork-me-on-github"><a href="#右上角加fork-me-on-github" class="headerlink" title="右上角加fork me on github"></a><a href="#右上角加fork-me-on-github" title="右上角加fork me on github"></a>右上角加fork me on github</h4><p>点击<a href="http://tholman.com/github-corners/" rel="external nofollow noopener noreferrer" target="_blank">这里</a>或者<a href="https://github.com/blog/273-github-ribbons" rel="external nofollow noopener noreferrer" target="_blank">这里</a>挑选你喜欢的样式，修改成你的GitHub链接，复制到<code>themes/next/layout/_layout.swig</code>文件中的以下位置：  </p>
<figure class="highlight"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></div><div class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"&#123;&#123; container\_class &#125;&#125; &#123;% block page\_class %&#125;&#123;% endblock %&#125;"</span>&gt;</span>  </div><div class="line"> <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"headband"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span>  </div><div class="line"> &lt;a href="https://github.com/JianFengY" ......&lt;/a&gt;</div></pre></div></div></figure>
<h4 id="浏览文章时显示浏览进度"><a href="#浏览文章时显示浏览进度" class="headerlink" title="浏览文章时显示浏览进度"></a><a href="#浏览文章时显示浏览进度" title="浏览文章时显示浏览进度"></a>浏览文章时显示浏览进度</h4><p>主题设置文件查找<code>scrollpercent</code>修改为<code>true</code>：  </p>
<figure class="highlight yml"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></div><div class="code"><pre><div class="line"><span class="comment"># Scroll percent label in b2t button.  </span></div><div class="line"><span class="attr">scrollpercent:</span> <span class="literal">true</span></div></pre></div></div></figure>
<h4 id="修改文章内链接的样式"><a href="#修改文章内链接的样式" class="headerlink" title="修改文章内链接的样式"></a><a href="#修改文章内链接的样式" title="修改文章内链接的样式"></a>修改文章内链接的样式</h4><p>文章里的链接样式默认是只加一条下划线，颜色和普通文字一样，为了方便区分，在<code>themes/next/source/css/_custom/custom.styl</code>文件加以下代码，自行添加的样式都可以写在这个文件里：  </p>
<figure class="highlight css"><div class="figcode"><div class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></div><div class="code"><pre><div class="line"><span class="selector-class">.post-body</span> <span class="selector-tag">p</span> <span class="selector-tag">a</span>&#123;  </div><div class="line"> <span class="attribute">color</span>: <span class="number">#0593d3</span>;  </div><div class="line"> <span class="attribute">border-bottom</span>: none;  </div><div class="line"> <span class="attribute">border-bottom</span>: <span class="number">1px</span> solid <span class="number">#0593d3</span>;  </div><div class="line"> &amp;:hover &#123;  </div><div class="line"> <span class="selector-tag">color</span>: <span class="selector-id">#fc6423</span>;  </div><div class="line"> <span class="selector-tag">border-bottom</span>: <span class="selector-tag">none</span>;  </div><div class="line"> <span class="selector-tag">border-bottom</span>: 1<span class="selector-tag">px</span> <span class="selector-tag">solid</span> <span class="selector-id">#fc6423</span>;  </div><div class="line"> &#125;  </div><div class="line"> &#125;</div></pre></div></div></figure>
<h3 id="致谢"><a href="#致谢" class="headerlink" title="致谢"></a><a href="#致谢" title="致谢"></a>致谢</h3><p>这个博客从搭建到美化，都参考了网上许多文章和教程，我就不一一罗列出来了，感谢网上各路大神！</p>
<p>这里推荐一篇干货满满的文章：<a href="https://www.jianshu.com/p/f054333ac9e6" rel="external nofollow noopener noreferrer" target="_blank">https://www.jianshu.com/p/f054333ac9e6</a></p>
<p>还有就是官方的文档了，里面也有很详细的主题配置和第三方服务的说明：<a href="http://theme-next.iissnan.com/third-party-services.html" rel="external nofollow noopener noreferrer" target="_blank">http://theme-next.iissnan.com/third-party-services.html</a></p>

      
    </div>

    
      


    

    
    
    
    
    <div>
        
        <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
        
    </div>
    
    <div>
          
            

          
    </div>

    
      <div>
        <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/uploads/wechat-qcode.jpg" alt="yszar wechat" style="width: 200px; max-width: 100%;">
    <div>欢迎您扫一扫上面的微信公众号，订阅我的博客！</div>
</div>

      </div>
    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/uploads/wxfk.png" alt="yszar 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/uploads/zfbfk.png" alt="yszar 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Hexo/" rel="tag"><i class="fa fa-tag"></i> Hexo</a>
          
            <a href="/tags/Next/" rel="tag"><i class="fa fa-tag"></i> Next</a>
          
            <a href="/tags/美化/" rel="tag"><i class="fa fa-tag"></i> 美化</a>
          
            <a href="/tags/配置/" rel="tag"><i class="fa fa-tag"></i> 配置</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        
          <div class="wp_rating">
          <div style="color: rgba(0, 0, 0, 0.75); font-size:13px; letter-spacing:3px">(&gt;看完记得五星好评哦亲&lt;)</div>
            <div id="wpac-rating"></div>
          </div>
        

        

        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
            
              
              <a href="/hexo-blog-next-theme-seo-optimization-method.html" rel="prev" title="Hexo博客Next主题SEO优化方法">
                
                <i class="fa fa-chevron-left"></i> Hexo博客Next主题SEO优化方法
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
            
              
              <a href="/linuxls-directory-color-configuration.html" rel="next" title="linux-ls目录颜色配置">
                
                linux-ls目录颜色配置 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  
       <div id="gitalk-container"></div>
       <link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">yszar</p>
              <p class="site-description motion-element" itemprop="description">学无止境！</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">21</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">5</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">42</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/yszar" target="_blank" title="GitHub" rel="external nofollow noopener noreferrer"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:yszar@vip.qq.com" target="_blank" title="E-Mail" rel="external nofollow noopener noreferrer"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  
                </span>
              
            </div>
          

          
          
            <div class="cc-license motion-element" itemprop="license">
              <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank" rel="external nofollow noopener noreferrer">
                <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons">
              </a>
            </div>
          

          
          

          
            
          
          
        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#安装Next主题"><span class="nav-number">1.</span> <span class="nav-text">安装Next主题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#博客设置"><span class="nav-number">2.</span> <span class="nav-text">博客设置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#设置语言"><span class="nav-number">2.1.</span> <span class="nav-text">设置语言</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#基本信息"><span class="nav-number">2.2.</span> <span class="nav-text">基本信息</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#主题设置"><span class="nav-number">3.</span> <span class="nav-text">主题设置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#设置主题的Scheme"><span class="nav-number">3.1.</span> <span class="nav-text">设置主题的Scheme</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#菜单设置"><span class="nav-number">3.2.</span> <span class="nav-text">菜单设置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#创建页面"><span class="nav-number">3.3.</span> <span class="nav-text">创建页面</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#文章显示设置"><span class="nav-number">3.4.</span> <span class="nav-text">文章显示设置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#使用RSS"><span class="nav-number">3.5.</span> <span class="nav-text">使用RSS</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#设置头像"><span class="nav-number">3.6.</span> <span class="nav-text">设置头像</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#设置博客favicon图标"><span class="nav-number">3.7.</span> <span class="nav-text">设置博客favicon图标</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#侧边栏社交链接"><span class="nav-number">3.8.</span> <span class="nav-text">侧边栏社交链接</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#设置背景动画"><span class="nav-number">3.9.</span> <span class="nav-text">设置背景动画</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#修改文章底部的-号标签"><span class="nav-number">3.10.</span> <span class="nav-text">修改文章底部的#号标签</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#评论系统"><span class="nav-number">3.11.</span> <span class="nav-text">评论系统</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#网站底部加访问量"><span class="nav-number">3.12.</span> <span class="nav-text">网站底部加访问量</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#统计功能"><span class="nav-number">3.13.</span> <span class="nav-text">统计功能</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#LeanCloud文章阅读次数统计"><span class="nav-number">3.14.</span> <span class="nav-text">LeanCloud文章阅读次数统计</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#搜索服务Local-Search"><span class="nav-number">3.15.</span> <span class="nav-text">搜索服务Local Search</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#顶部加载条"><span class="nav-number">3.16.</span> <span class="nav-text">顶部加载条</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#右上角加fork-me-on-github"><span class="nav-number">3.17.</span> <span class="nav-text">右上角加fork me on github</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#浏览文章时显示浏览进度"><span class="nav-number">3.18.</span> <span class="nav-text">浏览文章时显示浏览进度</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#修改文章内链接的样式"><span class="nav-number">3.19.</span> <span class="nav-text">修改文章内链接的样式</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#致谢"><span class="nav-number">4.</span> <span class="nav-text">致谢</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  
  <span class="with-love" id="heart">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yszar</span>

  

  
</div>


  










<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共38.6k字</span>
</div>
<div class="post-count">
	<a href="http://www.miitbeian.gov.cn/" rel="external nofollow noopener noreferrer" target="_blank">陇ICP备15003024号</a>
</div>


<div class="weixin-box">
  <div class="weixin-menu">
    <div class="weixin-hover">
      <div class="weixin-description">微信扫一扫，订阅本博客</div>
    </div>
  </div>
</div>
        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>












  















  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/npm/jquery@2.1.3/dist/jquery.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.ui.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.2"></script>



  



  










   
     
       <script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>

      <script src="/js/src/md5.min.js"></script>

       <script type="text/javascript">
         const gitalk = new Gitalk({
           clientID: '54f26977793794b45255',
           clientSecret: '568cccb3bdde42eca6c05ab0680b4617bbb58c4f',
           repo: 'yszar.github.io',
           owner: 'yszar',
           admin: 'yszar'.split(','),
           id: md5(location.pathname),
           pagerDirection: 'first',
           // facebook-like distraction free mode
           distractionFreeMode: false
         })
         gitalk.render('gitalk-container')
       </script>
     
   
 
  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  
  <script>
    
    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();

      Counter('get', '/classes/Counter', { where: JSON.stringify({ url }) })
        .done(function ({ results }) {
          if (results.length > 0) {
            var counter = results[0];
            
              var $element = $(document.getElementById(url));
              $element.find('.leancloud-visitors-count').text(counter.time + 1);
            
            Counter('put', `/classes/Counter/${counter.objectId}`, JSON.stringify({ time: { "__op":"Increment", "amount":1 } }))
            
            .fail(function ({ responseJSON }) {
                console.log('Failed to save Visitor num, with error message: ' + responseJSON.error);
            })
          } else {
            
              Counter('post', '/classes/Counter', JSON.stringify({ title: title, url: url, time: 1}))
                .done(function () {
                  var $element = $(document.getElementById(url));
                  $element.find('.leancloud-visitors-count').text(1);
                })
                .fail(function () {
                  console.log('Failed to create');
                });
            
          }
        })
      .fail(function ({ responseJSON }) {
        console.log('LeanCloud Counter Error:' + responseJSON.code + " " + responseJSON.error);
      });
    }
    

    $(function() {
      $.get('https://app-router.leancloud.cn/2/route?appId=' + "iUS887d8BnkY3Gqc9FJX70fE-gzGzoHsz")
        .done(function ({ api_server }) {
          var Counter = function (method, url, data) {
            return $.ajax({
              method: method,
              url: `https://${api_server}/1.1${url}`,
              headers: {
                'X-LC-Id': "iUS887d8BnkY3Gqc9FJX70fE-gzGzoHsz",
                'X-LC-Key': "ekF4kKyQDgrDkIBadj3IDrVA",
                'Content-Type': 'application/json',
              },
              data: data,
            });
          };
          
          addCount(Counter);
          
        })
    });
  </script>



  

  

  

  
  
  <script type="text/javascript">
  wpac_init = window.wpac_init || [];
  wpac_init.push({widget: 'Rating', id: 14244,
    el: 'wpac-rating',
    color: 'fc6423'
  });
  (function() {
    if ('WIDGETPACK_LOADED' in window) return;
    WIDGETPACK_LOADED = true;
    var mc = document.createElement('script');
    mc.type = 'text/javascript';
    mc.async = true;
    mc.src = '//embed.widgetpack.com/widget.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);
  })();
  </script>


  

  

  

  

  
  <style>
    .copy-btn {
      display: inline-block;
      padding: 6px 12px;
      font-size: 13px;
      font-weight: 700;
      line-height: 20px;
      color: #333;
      white-space: nowrap;
      vertical-align: middle;
      cursor: pointer;
      background-color: #eee;
      background-image: linear-gradient(#fcfcfc, #eee);
      border: 1px solid #d5d5d5;
      border-radius: 3px;
      user-select: none;
      outline: 0;
    }

    .highlight-wrap .copy-btn {
      transition: opacity .3s ease-in-out;
      opacity: 0;
      padding: 2px 6px;
      position: absolute;
      right: 4px;
      top: 8px;
    }

    .highlight-wrap:hover .copy-btn,
    .highlight-wrap .copy-btn:focus {
      opacity: 1
    }

    .highlight-wrap {
      position: relative;
    }
  </style>
  <script>
    $('.highlight').each(function (i, e) {
      var $wrap = $('<div>').addClass('highlight-wrap')
      $(e).after($wrap)
      $wrap.append($('<button>').addClass('copy-btn').append('复制').on('click', function (e) {
        var code = $(this).parent().find('.code').find('.line').map(function (i, e) {
          return $(e).text()
        }).toArray().join('\n')
        var ta = document.createElement('textarea')
        document.body.appendChild(ta)
        ta.style.position = 'absolute'
        ta.style.top = '0px'
        ta.style.left = '0px'
        ta.value = code
        ta.select()
        ta.focus()
        var result = document.execCommand('copy')
        document.body.removeChild(ta)
        
          if(result)$(this).text('复制成功')
          else $(this).text('复制失败')
        
        $(this).blur()
      })).on('mouseleave', function (e) {
        var $b = $(this).find('.copy-btn')
        setTimeout(function () {
          $b.text('复制')
        }, 300)
      }).append(e)
    })
  </script>


  
</body>
</html>
